home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 6
/
006.d81
/
pps #13
< prev
next >
Wrap
Text File
|
2022-08-26
|
2KB
|
148 lines
PEEKs, POKEs, and SYSes -- Part 13
by Jimmy Weiler
======================================
Location:65520 Hexadecimal: $FFF0
Official Label: PLOT Type: ROM
Useful BASIC commands: SYS
======================================
PLOT has two functions. It can tell
you where the cursor is on the screen
and it can place the cursor anywhere
on the screen.
It is relatively simple to use:
To place the cursor 9 across and 12
down:
10POKE782,9:POKE781,12:POKE783,0:SYS
65520
To read the current cursor position:
10POKE783,1:SYS65520:HRIZ=PEEK(782):
VERT=PEEK(781)
* Warning!! NEVER plot a position that
* is not on the screen. Results are
* unpredictable and often fatal to
* everything in memory.
You can achieve an effect similar to
PLOT by using the cursor direction
keys. This is most easily illustrated
with a short program.
10 GOSUB 100
20 INPUT "HORIZ & VERT POSITIONS";H,V
25 PRINT "<clr>"
30 PRINT LEFT$ (ACROSS$,H+1);
40 PRINT LEFT$ (DOWN$,V);
50 PRINT "HERE."
60 GOTO 20
100 rem string initialization
110 ACROSS$ = "<home>"
120 FOR C = 1 TO 40
130 ACROSS$ = ACROSS$ + "<crsr rt>"
140 NEXT C
150 FOR C = 1 TO 25
160 DOWN$ = DOWN$ + "<crsr dn>"
170 NEXT C
180 RETURN
As you can see, PLOT may result in
substantial code compression.
How PLOT works:
(This may get a bit technical. If
you don't understand it, it's safe
to ignore it.)
Locations 781, 782, and 783 are for
temporary storage of the processor X,
Y, and STATUS registers.
Plot first checks the status
register's CARRY flag. If it is
reset plot will move the cursor to the
horizontal position found in the Y
register (782), and the vertical
position found in X (781). [The carry
flag is bit 0 of the status register,
so POKE 783,0 resets the carry flag
and all the other flags.]
If carry is set (poke 783,1),
then PLOT calculates the cursor's
current position and places the
horizontal coordinate in Y (782) and
the vertical in X (781). You can then
peek X and Y and use the values in
your BASIC program.
And a final note: the carry flag is
volatile. Many BASIC functions set
and reset the carry flag. If you
use PLOT, you should poke the carry
status EVERY time you PLOT and not
just once at the beginning of your
program.
--------------------------------------